home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / etc / acpi / resume.d / 90-hdparm.sh < prev    next >
Encoding:
Linux/UNIX/POSIX Shell Script  |  2009-03-27  |  1.1 KB  |  42 lines

  1. #! /bin/sh
  2. #
  3. # This script adjusts hard drive APM settings using hdparm. The hardware
  4. # defaults (usually hdparm -B 128) cause excessive head load/unload cycles
  5. # on many modern hard drives. We therefore set hdparm -B 254 while on AC
  6. # power. On battery we set hdparm -B 128, because the head parking is
  7. # very useful for shock protection.
  8. #
  9.  
  10. . /usr/share/acpi-support/power-funcs
  11.  
  12. DO_HDPARM=y
  13. if [ -e /usr/sbin/laptop_mode ] ; then 
  14.   LMT_CONTROL_HD_POWERMGMT=$(. /etc/laptop-mode/laptop-mode.conf && echo "$CONTROL_HD_POWERMGMT")
  15.   if [ "$LMT_CONTROL_HD_POWERMGMT" != 0 ] \
  16.      && [ -e /var/run/laptop-mode-tools/enabled ]
  17.   then
  18.     # Laptop mode controls hdparm -B settings, we don't.
  19.     DO_HDPARM=n
  20.   fi
  21. fi
  22.  
  23. if [ "$DO_HDPARM" = y ] ; then
  24.   # Get the power state into STATE
  25.   getState;
  26.   
  27.   for dev in /dev/sd? /dev/hd? ; do
  28.     if [ -b $dev ] ; then
  29.       # Check for APM support; discard errors since not all drives
  30.       # support HDIO_GET_IDENTITY (-i).    
  31.       if hdparm -i $dev 2> /dev/null | grep -q 'AdvancedPM=yes' ; then
  32.     if [ "$STATE" = "BATTERY" ] ; then
  33.       hdparm -B 128 $dev
  34.     else
  35.       hdparm -B 254 $dev
  36.     fi
  37.       fi
  38.     fi
  39.   done
  40. fi
  41.  
  42.